
public class Watchdog extends  Thread {

	private int maDuree;
	private ModelConnexion maConnexion;
	private int stop;

 
	/**
	 *  Duree en seconde
	 * @param matelot 
	 */
	public Watchdog(int Duree) {
		super();
		maDuree = Duree;
		stop = 2;
	}
 
	public void run(){
		while (true)
		{
			try {
				Thread.sleep(maDuree);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			if(stop == 0){
				String message = new String("HM");
				System.out.println("Signal Homme Mort");
				maConnexion.sendMessage(message);

			}
			
			
		}
		
	}
 
	/*
	 * reinitialise le watchdog
	 */
	public void stopEmission(){
		stop = 1;
	}
	public void startEmission(){
		stop = 0;
	}

	public void setModelConnexion(ModelConnexion modelConnexion) {
		maConnexion = modelConnexion;
		
	}
 
}
